package com;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;

public class get  extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext context = this.getServletContext();
        context.setAttribute("name","liquan");
        //获取初始化参数
        System.out.println(context.getInitParameter("url"));
        //获取真实路径
        String realPath = context.getRealPath("/WEB-INF/static/ac.txt");
        System.out.println(realPath);
        //获取资源流
        InputStream resourceAsStream = context.getResourceAsStream("/WEB-INF/static/ac.txt");
        //获取指定路径下所有文件路径
        Set<String> set = context.getResourcePaths("/WEB-INF");
        System.out.println(set);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       doGet(req,resp);
    }
}
